#ifndef _GH_UTILS_H_
#define _GH_UTILS_H_

#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <chrono>

namespace gh_util {

    inline std::chrono::steady_clock::time_point now() {
        return std::chrono::steady_clock::now();
    }

    inline std::chrono::system_clock::time_point system_now() {
        return std::chrono::system_clock::now();
    }

/* duration */
    inline int64_t
    duration_ms(std::chrono::steady_clock::time_point &begin, std::chrono::steady_clock::time_point &end) {
        return std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
    }

    inline int64_t
    duration_us(std::chrono::steady_clock::time_point &begin, std::chrono::steady_clock::time_point &end) {
        return std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count();
    }

/* timestamp */
    inline int64_t timestamp_ms(std::chrono::system_clock::time_point &&now) {
        return std::chrono::time_point_cast<std::chrono::milliseconds>(now).time_since_epoch().count();
    }

    inline int64_t timestamp_sec(std::chrono::system_clock::time_point &&now) {
        return std::chrono::time_point_cast<std::chrono::seconds>(now).time_since_epoch().count();
    }
}
#endif